/*
 * ECARX Technology Limited is the owner of the copyright and the trade secret of this software.
 * Without permission, no one has the right to obtain, disclose or use this software in any way.
 */
package com.ecarx.systemui.plugin.ui.statusbar

import android.content.Context
import android.graphics.Color
import android.util.AttributeSet
import android.view.Gravity
import android.view.View
import android.widget.TextClock
import androidx.core.content.ContextCompat
import com.ecarx.systemui.plugin.PluginContext
import com.ecarx.systemui.plugin.R
import com.ecarx.systemui.plugin.ui.dialog.base.DialogManager
import com.ecarx.systemui.plugin.utils.LogUtils


class TimeView : TextClock {

    constructor(context: Context?) : this(context!!, null) {
    }

    constructor(context: Context?, attrs: AttributeSet?) : this(context!!, attrs, 0) {
    }

    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context!!,
        attrs,
        defStyleAttr) {
        initView()
    }

    fun initView() {

        id = generateViewId()
        LogUtils.d(TAG, javaClass.name + "id:$id")

        setSingleLine()
        gravity = Gravity.CENTER
        setTextColor(ContextCompat.getColor(context, R.color.color_A1A4B3))

        setOnClickListener { v: View? ->
            LogUtils.d(TAG, "Click TimeView >>>>>>>. ")
            DialogManager.getDialogManager().showCalendarTimeDialog(PluginContext.getInstance().pluginContext, true)
        }

    }

    override fun onFinishInflate() {
        super.onFinishInflate()

    }

    companion object {
        private const val TAG = "TimeView"
    }
}